﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="__ADMIN__/layui/css/layui.css" />
<title>文章列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> {$name} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<form action="" method="post">
			<input type="text" class="input-text" style="display: none" id="id" name="id" {if $id}value="{$id}"{/if}>
		<input type="text" class="input-text" style="width:250px" placeholder="搜索" id="tiaojian" name="tiaojian" {if $tiaojian}value="{$tiaojian}"{/if}>
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜文档</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" onclick="dels()" class="btn btn-danger radius">
				<i class="Hui-iconfont">&#xe6e2;</i> 批量删除
			</a>
			{if $pid}
			<a href="javascript:;" onclick="articlecon_add('添加文档','{:url('document/show_add')}?pid={$pid}','800','700')" class="btn btn-primary radius">
				{else}
				<a href="javascript:;" onclick="articlecon_add('添加文档','{:url('document/show_add')}','800','700')" class="btn btn-primary radius">
				{/if}
				<i class="Hui-iconfont">&#xe600;</i> 添加文档
			</a>
		</span> 
		<span class="r">共有数据：<strong>{$datarows}</strong> 条</span>
	</div>
	<br/>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="13">文档列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th >ID</th>
				<th>文档名称</th>
				<th>上级文档</th>
				<th>地址描述</th>
				<th>模型</th>
				<th>是否已启用</th>
				<th>点击查看</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		{if count($data)}
		{foreach $data as $value}
			<tr class="text-c">
				<td><input type="checkbox" value="{$value['id']}" name="userid"></td>
				<td>{$value['id']}</td>
				<td>
					{$value['title']}
				</td>
				<td>{$value['pidname']}</td>
				<td>{$value['dir']}</td>
				<td>{$value['model_name']}</td>
				<td>
					{if $value['status']==1}
					<span class="label label-success radius">已启用</span>
					{else}
					<span class="label radius">已禁用</span>
					{/if}
				</td>
				<td><a title="查看详情" href="javascript:;" onclick="info('详情','{$value['id']}','800','700')" class="ml-5" style="text-decoration:none">查看详情</a></td>
				{if $pid}
				<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit('编辑','{:url('document/edit_p')}?id={$value['id']}&pid={$pid}','800','600')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,'{$value['id']}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				{else}
				<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit('编辑','{:url('document/edit_p')}?id={$value['id']}','800','600')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,'{$value['id']}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				{/if}
			</tr>
		{/foreach}
		{else}
		<tr><td colspan="13" style="text-align: center">什么都没查到</td></tr>
		{/if}
		</tbody>
	</table>
	<div style="text-align: center">
		<div id="test1"></div>
	</div>

</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__ADMIN__/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="__ADMIN__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__ADMIN__/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="__ADMIN__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ADMIN__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__ADMIN__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__ADMIN__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__ADMIN__/layui/layui.all.js"></script>
<script type="text/javascript" src="__ADMIN__/js/maowenke.js"></script>
<script type="text/javascript">
	function info(title,id,w,h) {
		layer_shows(title,"{:url('info/show')}?id="+id,w,h);
    }
//	function art_info(title,id,w,h) {
//		layer_shows(title,"{:url('info/art')}?id="+id,w,h);
//    }
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: parseInt('{$datarows}') //数据总数，从服务端得到
			,layout:['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
			,limits:[10,20,30,40,50]
            ,jump:function (obj,first) {
                console.log(obj);
                if(!first){
                    var $tiaojian = $("#tiaojian").val();
                    ajaxUpdate('{:url("document/page")}',{page:obj.curr,tiaojian:$tiaojian,id:"{$id}",limit:obj.limit},'true','post',function (data) {
                        console.log(data);
                        $("tbody").empty();
                        var $str = '';
                        var $status = '';
                        $.each(data,function(i,v){
                            $str = '';
                            $status = '';
                            if(v.status==1){
                                $status = '<span class="label label-success radius">已启用</span>';
							}else{
                                $status = '<span class="label radius">已禁用</span>';
							}
								$str = '<tr class="text-c">'+
                                    '<td><input type="checkbox" value="'+v.id+'" name="userid"></td>'+
                                '<td>'+v.id+'</td>'+
                                '<td>'+tostr(v.title)+'</td>'+
                                '<td>'+tostr(v.pidname)+'</td>'+
                                '<td>'+tostr(v.dir)+'</td>'+
                                '<td>'+tostr(v.model_name)+'</td>'+
                                '<td>'+$status+'</td>'+
                            '<td><a title="查看详情" href="javascript:;" onclick="info(\'详情\',\''+v.id+'\',\'800\',\'600\')" class="ml-5" style="text-decoration:none">查看详情</a></td>'+
                                '<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit(\'编辑\',\'{:url("document/edit_p")}?id='+v.id+'&pid={$pid}\',\'800\',\'600\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,\''+v.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'+
                            '</tr>';
							$("tbody").append($str);
                        })
                    })
                }
            }
        });
    });

/*类容-增加*/
function articlecon_add(title,url,w,h){
   var $page = $(".layui-laypage-curr").children('em').eq(1).text();
   var $limit = $('select').val();
   var $tiaojian = $("#tiaojian").val();
	layer_show(title,url,w,h,function () {
	    console.log($page);
        ajaxUpdate('{:url("document/page")}',{page:$page,tiaojian:$tiaojian,id:"{$id}",limit:$limit},'true','post',function (data) {
            console.log(data);
            $("tbody").empty();
            var $str = '';
            var $status = '';
            $.each(data,function(i,v){
                $str = '';
                $status = '';
                if(v.status==1){
                    $status = '<span class="label label-success radius">已启用</span>';
                }else{
                    $status = '<span class="label radius">已禁用</span>';
                }
                $str = '<tr class="text-c">'+
                    '<td><input type="checkbox" value="'+v.id+'" name="userid"></td>'+
                    '<td>'+v.id+'</td>'+
                    '<td>'+tostr(v.title)+'</td>'+
                    '<td>'+tostr(v.pidname)+'</td>'+
                    '<td>'+tostr(v.dir)+'</td>'+
                    '<td>'+tostr(v.model_name)+'</td>'+
                    '<td>'+$status+'</td>'+
                    '<td><a title="查看详情" href="javascript:;" onclick="info(\'详情\',\''+v.id+'\',\'800\',\'600\')" class="ml-5" style="text-decoration:none">查看详情</a></td>'+
                    '<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit(\'编辑\',\'{:url("document/edit_p")}?id='+v.id+'&pid={$pid}\',\'800\',\'600\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,\''+v.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'+
                    '</tr>';
                $("tbody").append($str);
            })
        })
    });
}
function showcontent($id) {
	layer_show('文章内容','{:url("articlecon/show_content")}?id='+$id,'800','800');
}
/*类容-删除*/
function del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
        ajaxUpdate('{:url("document/del")}',{id:id},'true','post',function (data) {
            console.log(data);
            if(data==1){
                layer.msg('删除成功');
                var $page = $(".layui-laypage-curr").children('em').eq(1).text();
                var $limit = $('select').val();
                var $tiaojian = $("#tiaojian").val();
                ajaxUpdate('{:url("document/page")}',{page:$page,tiaojian:$tiaojian,id:"{$id}",limit:$limit},'true','post',function (data) {
                    console.log(data);
                    $("tbody").empty();
                    var $str = '';
                    var $status = '';
                    $.each(data,function(i,v){
                        $str = '';
                        $status = '';
                        if(v.status==1){
                            $status = '<span class="label label-success radius">已启用</span>';
                        }else{
                            $status = '<span class="label radius">已禁用</span>';
                        }
                        $str = '<tr class="text-c">'+
                            '<td><input type="checkbox" value="'+v.id+'" name="userid"></td>'+
                            '<td>'+v.id+'</td>'+
                            '<td>'+tostr(v.title)+'</td>'+
                            '<td>'+tostr(v.pidname)+'</td>'+
                            '<td>'+tostr(v.dir)+'</td>'+
                            '<td>'+tostr(v.model_name)+'</td>'+
                            '<td>'+$status+'</td>'+
                            '<td><a title="查看详情" href="javascript:;" onclick="info(\'详情\',\''+v.id+'\',\'800\',\'600\')" class="ml-5" style="text-decoration:none">查看详情</a></td>'+
                            '<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit(\'编辑\',\'{:url("document/edit_p")}?id='+v.id+'&pid={$pid}\',\'800\',\'600\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,\''+v.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'+
                            '</tr>';
                        $("tbody").append($str);
                    })
                })
            }else{
                layer.msg(data);
            }
        })
	});
}

/*类容-编辑*/
function articlecon_edit(title,url,w,h){
    var $page = $(".layui-laypage-curr").children('em').eq(1).text();
    var $limit = $('select').val();
    var $tiaojian = $("#tiaojian").val();
	layer_show(title,url,w,h,function () {
        ajaxUpdate('{:url("document/page")}',{page:$page,tiaojian:$tiaojian,id:"{$id}",limit:$limit},'true','post',function (data) {
            console.log(data);
            $("tbody").empty();
            var $str = '';
            var $status = '';
            $.each(data,function(i,v){
                $str = '';
                $status = '';
                if(v.status==1){
                    $status = '<span class="label label-success radius">已启用</span>';
                }else{
                    $status = '<span class="label radius">已禁用</span>';
                }
                $str = '<tr class="text-c">'+
                    '<td><input type="checkbox" value="'+v.id+'" name="userid"></td>'+
                    '<td>'+v.id+'</td>'+
                    '<td>'+tostr(v.title)+'</td>'+
                    '<td>'+tostr(v.pidname)+'</td>'+
                    '<td>'+tostr(v.dir)+'</td>'+
                    '<td>'+tostr(v.model_name)+'</td>'+
                    '<td>'+$status+'</td>'+
                    '<td><a title="查看详情" href="javascript:;" onclick="info(\'详情\',\''+v.id+'\',\'800\',\'600\')" class="ml-5" style="text-decoration:none">查看详情</a></td>'+
                    '<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit(\'编辑\',\'{:url("document/edit_p")}?id='+v.id+'&pid={$pid}\',\'800\',\'600\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,\''+v.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'+
                    '</tr>';
                $("tbody").append($str);
            })
        })
    });
}
/*类容-停用*/
function articlecon_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
        ajaxUpdate('{:url("articlecon/articlecon_stop")}',{id:id},'true','post',function (data) {
            if(data==1){
                $(obj).parents("tr").find(".td-manage").prepend('<a onClick="articlecon_start(this,'+id+')" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
                $(obj).remove();
                layer.msg('已停用!',{icon: 5,time:1000});
            }else{
                layer.msg(data);
            }
        })
	});
}
/*类容-启用*/
function articlecon_start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
	    ajaxUpdate('{:url("articlecon/articlecon_start")}',{id:id},'true','post',function (data) {
            if(data==1){
                $(obj).parents("tr").find(".td-manage").prepend('<a onClick="articlecon_stop(this,'+id+')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                $(obj).remove();
                layer.msg('已启用!', {icon: 6,time:1000});
            }else{
                layer.msg(data);
            }
        })
	});
}

    /**
     * 批量删除内容
     */
    function dels() {
    var $input = $("input[name=userid]");
    var idarr = [];
    $.each($input,function (i,v) {
        if($(v).prop('checked')){
            idarr.push($(v).val());
        }
    });
        layer.confirm('确认要删除吗？',function(index){
            ajaxUpdate('{:url("document/del")}',{id:idarr},'true','post',function (data) {
                console.log(data);
                if(data==1){
                    layer.msg('删除成功');
                    var $page = $(".layui-laypage-curr").children('em').eq(1).text();
                    var $limit = $('select').val();
                    var $tiaojian = $("#tiaojian").val();
                    ajaxUpdate('{:url("document/page")}',{page:$page,tiaojian:$tiaojian,id:"{$id}",limit:$limit},'true','post',function (data) {
                        console.log(data);
                        $("tbody").empty();
                        var $str = '';
                        var $status = '';
                        $.each(data,function(i,v){
                            $str = '';
                            $status = '';
                            if(v.status==1){
                                $status = '<span class="label label-success radius">已启用</span>';
                            }else{
                                $status = '<span class="label radius">已禁用</span>';
                            }
                            $str = '<tr class="text-c">'+
                                '<td><input type="checkbox" value="'+v.id+'" name="userid"></td>'+
                                '<td>'+v.id+'</td>'+
                                '<td>'+tostr(v.title)+'</td>'+
                                '<td>'+tostr(v.pidname)+'</td>'+
                                '<td>'+tostr(v.dir)+'</td>'+
                                '<td>'+tostr(v.model_name)+'</td>'+
                                '<td>'+$status+'</td>'+
                                '<td><a title="查看详情" href="javascript:;" onclick="info(\'详情\',\''+v.id+'\',\'800\',\'600\')" class="ml-5" style="text-decoration:none">查看详情</a></td>'+
                                '<td class="td-manage"><a title="编辑" href="javascript:;" onclick="articlecon_edit(\'编辑\',\'{:url("document/edit_p")}?id='+v.id+'&pid={$pid}\',\'800\',\'600\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="del(this,\''+v.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'+
                                '</tr>';
                            $("tbody").append($str);
                        })
                    })
                }else{
                    layer.msg(data);
                }
            })
        });
}
</script>
</body>
</html>